#include<bits/stdc++.h>
using namespace std;

#define REP(i, l, r) for(int i = l; i <= r; ++i)
#define RREP(i, l, r) for(int i = l; i >= r; --i)
#define _REP(i, l, r, _) for(int i = l; i <= r; i += _)
#define _RREP(i, l, r, _) for(int i = l; i >= r; i -= _)

const int N = 1e5 + 10, M = 1e6 + 10;

int T, n, m, L, V, tot, s[M], p[N];
struct node
{
    int l, r;
} c[N];

bool cmp(node a, node b)
{
    return a.r == b.r ? a.l < b.l : a.r < b.r;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while(T--)
    {
        scanf("%d%d%d%d", &n, &m, &L, &V);
        tot = 0;
        REP(i, 1, n)
        {
            int d, v, a;
            scanf("%d%d%d", &d, &v, &a);
            if(a < 0)
            {
                if(v <= V) continue;
                double x = (1.0*V*V - 1.0*v*v) / 2.0 / a;
                c[++tot].l = d, c[tot].r = min(d+(int)ceil(x)-1, L);
            }
            else if(a == 0)
            {
                if(v <= V) continue;
                c[++tot].l = d, c[tot].r = L;
            }
            else
            {
                if(v > V)
                {
                    c[++tot].l = d, c[tot].r = L;
                    continue;
                }
                double x = (1.0*V*V - 1.0*v*v) / 2.0 / a;
                if(d+x >= L) continue;
                c[++tot].l = min(d+(int)floor(x)+1, L), c[tot].r = L;
            }
        }
        memset(s, 0, sizeof s);
        REP(i, 1, m)
        {
            scanf("%d", p + i);
            s[p[i]]++;
        }
        p[m + 1] = 0x3f3f3f3f;
        REP(i, 1, L) s[i] += s[i - 1];
        int tmp = tot, ans = 0, ls = 0, pt = 0; tot = 0;
        REP(i, 1, tmp) if(s[c[i].r] - s[c[i].l - 1]) c[++tot] = c[i];
        sort(c + 1, c + 1 + tot, cmp);/*
        REP(i, 1, tot)
        {
            cout << c[i].l << " " << c[i].r << endl;
        }
        REP(i, 1, m) cout << p[i] << " ";cout << endl;*/
        REP(i, 1, tot)
        {
            if(p[pt] >= c[i].l) continue;
            while(p[pt+1] <= c[i].r) pt++;
            ans++;
            ls = pt;//cout << i << " " << p[pt] << endl;
            if(pt == m) break;
        }
        printf("%d %d\n", tot, m - ans);
    }
    return 0;
}
